package com.seari.controller;

import javax.servlet.http.HttpServletRequest;

import org.apache.shiro.SecurityUtils;
import org.apache.shiro.session.Session;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;
import org.springframework.web.servlet.ModelAndView;

import com.seari.util.UuidUtil;

/**
 * 
 * @author 刘伟
 *
 */
public class BaseController {

	@Autowired
	protected HttpServletRequest request;

//	public static final String base_url = "https://www.socceretf.com";
	public static final String base_url = "http://localhost/fg";
//	public static final String base_url = "http://119.23.68.164:8099/fg";

	/**
	 * 得到ModelAndView
	 * 
	 * @return
	 */
	public ModelAndView getModelAndView() {
		return new ModelAndView();
	}

	/**
	 * 得到request对象
	 * 
	 * @return
	 */
	public HttpServletRequest getRequest() {
		HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes())
				.getRequest();
		return request;
	}

	/**
	 * shiro管理的session
	 * 
	 * @return
	 */
	public static Session getSession() {
		Session session = SecurityUtils.getSubject().getSession();
		session.setTimeout(1000 * 60 * 120);
		return session;
	}

	/**
	 * 得到32位的uuid
	 * 
	 * @return
	 */
	public String get32UUID() {

		return UuidUtil.get32UUID();
	}

}
